<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> 
<META HTTP-EQUIV="Expires" CONTENT="0"> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录界面</title>
</head>
<body>
<script language="javascript" src="JS/jquery-3.1.1.min.js"></script>
<script language="javascript">

function refresh(obj){
	obj.src="/baike/sdubaike/getCheckCodeImage?"+Math.random();
}
$(document).ready(function(){
	//alert("in")
	$("#sub").bind("click",function(){
		alert("发送请求");
		$.post("/baike/sdubaike/Login",{username:$("#Login_user").val(),password:$("#Login_pass").val(),checkCode:$("#Login_checkCode").val()},
				function callback(data){   
							
				           if(data!="success"){
				        	   alert(data);
				        	   refresh(document.getElementById("checkCode"));
				           }			        	  
				        	   	  
				           else
				        	   self.top.location.href='/baike/index.jsp';  				        	  			  
				        		
		   }); 
		});
	$("#submit").bind("click",function(){
		//alert("发送请求");
		$.post("/baike/sdubaike/Register",
				{username:$("#username").val(),password:$("#password").val(),email:$("#email").val()}
				,function callback(data){   
					alert(data);		        		
		   }); 
		});
	$("#username").bind("blur",function(){
		$.post("/baike/sdubaike/CheckExist"
				,{username:$("#username").val()}
				,function callback(data){
					alert(data)
				}
		);
	});
});
	

	
</script>


<b>登录：</b>
<form id="form1" action="###">
<b>用户名:</b>
<input type="text" name="user" id="Login_user">
<br>
<b>密&nbsp;&nbsp;&nbsp;&nbsp;码:</b>
<input type="password" name="pass" id="Login_pass">
<br>
<b>验&nbsp;&nbsp;证&nbsp;&nbsp;码:</b>
 <input type="text" name="randomCode" id="Login_checkCode"/><img id="checkCode" title="点击更换" onclick="javascript:refresh(this);" src="/baike/sdubaike/getCheckCodeImage"><br/>
<br>
<input type="button" value="提交" id="sub">
<input type="reset" value="清空">
</form>
<b>注册：</b>
<form id="form2" action="###">
<b>用户名:</b>
<input type="text" name="username" id="username"/>
<br>
<b>密&nbsp;&nbsp;&nbsp;&nbsp;码:</b>
<input type="password" name="password" id="password"/>
<br>
<b>邮&nbsp;&nbsp;&nbsp;&nbsp;箱:</b>
<input type="text" name="email" id="email"/>
<br>
<input type="button" id="submit" value="提交"/>
<input type="reset" value="清空">
<!-- <input type="submit"  value="提交"/> -->
</form>
<form action="/baike/forgetPass.jsp">
<input type="submit" value="忘记密码">

</form>
</body>
</html>